package com.bsit.obu.fragment;

import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

import com.bsit.obu.R;
import com.tianyuxinghang.sxmobileterm.bean.ObuSystemInformation;

import butterknife.BindView;
import butterknife.ButterKnife;

public class SystemFragment extends Fragment {
    @BindView(R.id.et_issue_identify)
    EditText et_issue_identify;

    @BindView(R.id.et_protel_ype)
    EditText et_protel_ype;

    @BindView(R.id.et_contract_version)
    EditText et_contract_version;

    @BindView(R.id.et_serl_no)
    EditText et_serl_no;

    @BindView(R.id.contract_markdate)
    EditText contract_markdate;

    @BindView(R.id.contract_overduedate)
    EditText contract_overduedate;

    @BindView(R.id.et_obu_stats)
    EditText et_obu_stats;


    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
      View  mView = inflater.inflate(R.layout.fragment_system, null);
        ButterKnife.bind(this, mView);
        et_issue_identify.setKeyListener(null);
        et_protel_ype.setKeyListener(null);
        et_contract_version.setKeyListener(null);
        et_serl_no.setKeyListener(null);
        contract_markdate.setKeyListener(null);
        contract_overduedate.setKeyListener(null);
        et_obu_stats.setOnKeyListener(null);
        return mView;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
    }

    public void updateUI(ObuSystemInformation obuInfo){
        et_issue_identify.setText(obuInfo.getProvider());

        et_protel_ype.setText(obuInfo.getType());

        et_contract_version.setText(obuInfo.getVersion());

        et_serl_no.setText(obuInfo.getSerialNumber());
        contract_markdate.setText(obuInfo.getSignedDate());

        contract_overduedate.setText(obuInfo.getExpiredDate());
        //obu拆卸状态
        et_obu_stats.setText(obuInfo.getTearFlag());
    }
}
